import React from 'react';
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/locale/zh_CN';

// 导入布局组件
import MainLayout from './components/layouts/MainLayout';

// 导入页面组件
import KnowledgeBaseList from './components/knowledgeBase/KnowledgeBaseList';
import DocumentList from './components/documents/DocumentList';
import QAPage from './pages/QAPage';
import LoginPage from './pages/LoginPage';
import NotFoundPage from './pages/NotFoundPage';

// 导入全局样式
import './assets/styles/index.css';

const App: React.FC = () => {
  return (
    <ConfigProvider locale={zhCN}>
      <Router>
        <Routes>
          {/* 公共路由 */}
          <Route path="/login" element={<LoginPage />} />
          
          {/* 需要身份验证的路由 */}
          <Route path="/" element={<MainLayout />}>
            <Route index element={<Navigate to="/dashboard" replace />} />
            <Route path="dashboard" element={<KnowledgeBaseList />} />
            <Route path="documents" element={<DocumentList />} />
            <Route path="knowledge-base/:id/documents" element={<DocumentList />} />
            <Route path="qa" element={<QAPage />} />
          </Route>
          
          {/* 404页面 */}
          <Route path="*" element={<NotFoundPage />} />
        </Routes>
      </Router>
    </ConfigProvider>
  );
};

export default App;
